package io.renren.modules.school.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.school.dao.SchoolPredictorDao;
import io.renren.modules.school.entity.SchoolPredictor;
import io.renren.modules.school.service.SchoolPredictorService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service("SchoolPredictorService")
public class SchoolPredictorServiceImpl extends ServiceImpl<SchoolPredictorDao, SchoolPredictor> implements SchoolPredictorService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String province= (String) params.get("q[province]");
        String region= (String) params.get("q[region]");
        String cities= (String) params.get("q[city]");
        String nature= (String) params.get("q[nature]");
        String level= (String) params.get("q[level]");
        Page<SchoolPredictor> page = this.selectPage(
                new Query<SchoolPredictor>(params).getPage(),
                new EntityWrapper<SchoolPredictor>()
                        .eq(StringUtils.isNotBlank(nature),"nature",nature)
                        .eq(StringUtils.isNotBlank(level),"level",level)
                        .like(StringUtils.isNotBlank(province),"province",province)
                        .like(StringUtils.isNotBlank(region),"region",region)
                        .like(StringUtils.isNotBlank(cities),"cities",cities)
        );

        return new PageUtils(page);
    }


}
